package 第七周.practice;
//SchoolBook2.java
//一个属性：表示本书读者年龄。其构造方法接受一个年龄参数。提供一个level方法，用于返回字符串。
public class SchoolBook2 extends Book2{
    private int ageLevel;
    //Constructor:Sets up the schoolbook with the
    //specified number of pages and age level(assumed
    //to be between 4 and 16 inclusive.)
    public SchoolBook2(int numPages, int age)
    {
        super(numPages);
        ageLevel = age;
    }
    //Returns a string that describes the age level.
    public String level(){
        if(ageLevel <= 6 && ageLevel>=4 )
            return "Pre-school";
        else
            if(ageLevel<=9)
                return "Early";
            else
                if(ageLevel<=12)
                    return"Middle";
                else
                    return "Upper";
    }
}

